package com.zzxx.mapper;

import com.zzxx.entity.Ticket;
import com.zzxx.entity.TicketExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TicketMapper extends TicketMapperEx{
    @SelectProvider(type=TicketSqlProvider.class, method="countByExample")
    long countByExample(TicketExample example);

    @DeleteProvider(type=TicketSqlProvider.class, method="deleteByExample")
    int deleteByExample(TicketExample example);

    @Delete({
        "delete from ticket",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into ticket (id, ticketType, ",
        "price, effectiveTime, ",
        "targetId, name, ",
        "src)",
        "values (#{id,jdbcType=VARCHAR}, #{tickettype,jdbcType=INTEGER}, ",
        "#{price,jdbcType=DOUBLE}, #{effectivetime,jdbcType=INTEGER}, ",
        "#{targetid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{src,jdbcType=VARCHAR})"
    })
    int insert(Ticket row);

    @InsertProvider(type=TicketSqlProvider.class, method="insertSelective")
    int insertSelective(Ticket row);

    @SelectProvider(type=TicketSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ticketType", property="tickettype", jdbcType=JdbcType.INTEGER),
        @Result(column="price", property="price", jdbcType=JdbcType.DOUBLE),
        @Result(column="effectiveTime", property="effectivetime", jdbcType=JdbcType.INTEGER),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="src", property="src", jdbcType=JdbcType.VARCHAR)
    })
    List<Ticket> selectByExample(TicketExample example);

    @Select({
        "select",
        "id, ticketType, price, effectiveTime, targetId, name, src",
        "from ticket",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="ticketType", property="tickettype", jdbcType=JdbcType.INTEGER),
        @Result(column="price", property="price", jdbcType=JdbcType.DOUBLE),
        @Result(column="effectiveTime", property="effectivetime", jdbcType=JdbcType.INTEGER),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="src", property="src", jdbcType=JdbcType.VARCHAR)
    })
    Ticket selectByPrimaryKey(String id);

    @UpdateProvider(type=TicketSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("row") Ticket row, @Param("example") TicketExample example);

    @UpdateProvider(type=TicketSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("row") Ticket row, @Param("example") TicketExample example);

    @UpdateProvider(type=TicketSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Ticket row);

    @Update({
        "update ticket",
        "set ticketType = #{tickettype,jdbcType=INTEGER},",
          "price = #{price,jdbcType=DOUBLE},",
          "effectiveTime = #{effectivetime,jdbcType=INTEGER},",
          "targetId = #{targetid,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "src = #{src,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Ticket row);
}